var express = require('express');
var router = express.Router();
var update = require('./update.js');

function explorerRe(name) {
    return function(req, res, next) {
        var b = req.query.hasOwnProperty(name);
        if (b) {
            return next()
        } else return next('route');
    }
}

router.all('/',explorerRe('explorer/fileUpload'), update);

router.get('/',explorerRe('explorer/fileDownload'), function(req, res, next) {
    res.download(req.query.path,null,{root:'/'});
});


module.exports = router;